SlideShare a Scribd company logo
Class No.03  Data Structures http://ecomputernotes.com
Linked List Actual picture in memory: 1051 1052 1055 1059 1060 1061 1062 1063 1064 1056 1057 1058 1053 1054 2 6 8 7 1 1051 1063 1057 1060 0 head 1054 1063 current 2 6 8 7 1 head current 1065 http://ecomputernotes.com
Linked List Operations add(9): Create a new node in memory to hold ‘9’ Node* newNode = new Node(9); 9 newNode http://ecomputernotes.com
Linked List Operations add(9): Create a new node in memory to hold ‘9’ Node* newNode = new Node(9); Link the new node into the list 9 newNode 2 6 8 7 1 head current size=5 6 9 newNode 1 3 2 http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode)  { this->nextNode = nextNode; }; private: int object; Node *nextNode; };   http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
#include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; }; http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
Building a Linked List headNode size=0 List list; http://ecomputernotes.com
Building a Linked List headNode 2 headNode currentNode size=1 lastcurrentNode size=0 List list; list.add(2); http://ecomputernotes.com
Building a Linked List headNode 2 headNode currentNode size=1 lastcurrentNode 2 6 headNode currentNode size=2 lastcurrentNode size=0 List list; list.add(2); list.add(6); http://ecomputernotes.com
Building a Linked List List.add(8); list.add(7); list.add(1); 2 6 7 1 headNode currentNode size=5 lastcurrentNode 8 http://ecomputernotes.com
C++ Code for Linked List int get() {  if (currentNode != NULL)  return currentNode->get();  }; http://ecomputernotes.com
C++ Code for Linked List bool next() { if (currentNode == NULL) return false; lastCurrentNode = currentNode; currentNode = currentNode->getNext(); if (currentNode == NULL || size == 0)  return false; else return true; }; http://ecomputernotes.com

More Related Content

PPT
Data structures cs301 power point slides lecture 03
PPT
Whats new in_csharp4
PPT
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
PPT
20100712-OTcl Command -- Getting Started
PDF
Python Performance 101
DOCX
Java practical
PPT
NS2: Binding C++ and OTcl variables
PPSX
What's new in C# 6 - NetPonto Porto 20160116
Data structures cs301 power point slides lecture 03
Whats new in_csharp4
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
20100712-OTcl Command -- Getting Started
Python Performance 101
Java practical
NS2: Binding C++ and OTcl variables
What's new in C# 6 - NetPonto Porto 20160116

What's hot (18)

PDF
Rainer Grimm, “Functional Programming in C++11”
DOC
Final JAVA Practical of BCA SEM-5.
PDF
Core java pract_sem iii
PDF
Java Practical File Diploma
PDF
DCN Practical
PDF
DSU C&C++ Practical File Diploma
DOCX
C# labprograms
PPTX
Poor Man's Functional Programming
PDF
Refactoring to Macros with Clojure
PDF
PPT
Networking Core Concept
PPTX
Java practice programs for beginners
PDF
Bartosz Milewski, “Re-discovering Monads in C++”
ZIP
とある断片の超動的言語
DOCX
Dotnet 18
PDF
Java practical(baca sem v)
PDF
JVM Mechanics: Understanding the JIT's Tricks
DOCX
C# console programms
Rainer Grimm, “Functional Programming in C++11”
Final JAVA Practical of BCA SEM-5.
Core java pract_sem iii
Java Practical File Diploma
DCN Practical
DSU C&C++ Practical File Diploma
C# labprograms
Poor Man's Functional Programming
Refactoring to Macros with Clojure
Networking Core Concept
Java practice programs for beginners
Bartosz Milewski, “Re-discovering Monads in C++”
とある断片の超動的言語
Dotnet 18
Java practical(baca sem v)
JVM Mechanics: Understanding the JIT's Tricks
C# console programms
Ad

Viewers also liked (20)

PPT
computer notes - Data Structures - 24
PPT
computer notes - Data Structures - 11
PPT
computer notes - Data Structures - 8
PPT
computer notes - Data Structures - 34
PPT
computer notes - Data Structures - 32
PPT
computer notes - Data Structures - 26
PPT
computer notes - Data Structures - 6
PPT
computer notes - Data Structures - 21
PPT
computer notes - Data Structures - 29
PPT
computer notes - Data Structures - 36
PPT
computer notes - Data Structures - 37
PPT
computer notes - Data Structures - 19
PPT
computer notes - Data Structures - 39
PPT
computer notes - Data Structures - 25
PPT
computer notes - Data Structures - 2
PPT
computer notes - Data Structures - 16
PPT
computer notes - Data Structures - 7
PPT
computer notes - Data Structures - 15
PPT
computer notes - Data Structures - 9
PPT
computer notes - Data Structures - 5
computer notes - Data Structures - 24
computer notes - Data Structures - 11
computer notes - Data Structures - 8
computer notes - Data Structures - 34
computer notes - Data Structures - 32
computer notes - Data Structures - 26
computer notes - Data Structures - 6
computer notes - Data Structures - 21
computer notes - Data Structures - 29
computer notes - Data Structures - 36
computer notes - Data Structures - 37
computer notes - Data Structures - 19
computer notes - Data Structures - 39
computer notes - Data Structures - 25
computer notes - Data Structures - 2
computer notes - Data Structures - 16
computer notes - Data Structures - 7
computer notes - Data Structures - 15
computer notes - Data Structures - 9
computer notes - Data Structures - 5
Ad

Similar to computer notes - Data Structures - 3 (20)

DOCX
C++ Please write the whole code that is needed for this assignment- wr.docx
PDF
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
PDF
ItemNodeh include ltiostreamgt include ltstring.pdf
PDF
could you implement this function please, im having issues with it..pdf
PDF
hi i have to write a java program involving link lists. i have a pro.pdf
PDF
This assignment and the next (#5) involve design and development of a.pdf
PPTX
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
PDF
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
PPT
Doublylinklist
PDF
Can you please debug this Thank you in advance! This program is sup.pdf
PDF
Rewrite this code so it can use a generic type instead of integers. .pdf
DOCX
Doubly linklist
DOCX
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
PDF
So I have this code(StackInAllSocks) and I implemented the method but.pdf
PDF
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
PPT
C++: Constructor, Copy Constructor and Assignment operator
PPTX
Link List Programming Linked List in Cpp
PDF
pleaase I want manual solution forData Structures and Algorithm An.pdf
PDF
How do you stop infinite loop Because I believe that it is making a.pdf
PDF
TutorialII_Updated____niceupdateprogram.pdf
C++ Please write the whole code that is needed for this assignment- wr.docx
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
ItemNodeh include ltiostreamgt include ltstring.pdf
could you implement this function please, im having issues with it..pdf
hi i have to write a java program involving link lists. i have a pro.pdf
This assignment and the next (#5) involve design and development of a.pdf
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Doublylinklist
Can you please debug this Thank you in advance! This program is sup.pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
Doubly linklist
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
So I have this code(StackInAllSocks) and I implemented the method but.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
C++: Constructor, Copy Constructor and Assignment operator
Link List Programming Linked List in Cpp
pleaase I want manual solution forData Structures and Algorithm An.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
TutorialII_Updated____niceupdateprogram.pdf

More from ecomputernotes (20)

PPT
computer notes - Data Structures - 30
PPT
computer notes - Data Structures - 20
DOC
Computer notes - Including Constraints
DOC
Computer notes - Date time Functions
DOC
Computer notes - Subqueries
DOC
Computer notes - Other Database Objects
PPT
computer notes - Data Structures - 28
PPT
computer notes - Data Structures - 31
PPT
computer notes - Data Structures - 4
PPT
computer notes - Data Structures - 13
DOC
Computer notes - Advanced Subqueries
DOC
Computer notes - Aggregating Data Using Group Functions
PPT
computer notes - Data Structures - 22
PPT
computer notes - Data Structures - 35
DOC
Computer notes - Enhancements to the GROUP BY Clause
DOC
Computer notes - Manipulating Data
DOC
Computer notes - Writing Basic SQL SELECT Statements
PPT
computer notes - Data Structures - 14
PPT
computer notes - Data Structures - 10
DOC
Computer notes - Controlling User Access
computer notes - Data Structures - 30
computer notes - Data Structures - 20
Computer notes - Including Constraints
Computer notes - Date time Functions
Computer notes - Subqueries
Computer notes - Other Database Objects
computer notes - Data Structures - 28
computer notes - Data Structures - 31
computer notes - Data Structures - 4
computer notes - Data Structures - 13
Computer notes - Advanced Subqueries
Computer notes - Aggregating Data Using Group Functions
computer notes - Data Structures - 22
computer notes - Data Structures - 35
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Manipulating Data
Computer notes - Writing Basic SQL SELECT Statements
computer notes - Data Structures - 14
computer notes - Data Structures - 10
Computer notes - Controlling User Access

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PPTX
Spectroscopy.pptx food analysis technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Encapsulation theory and applications.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Electronic commerce courselecture one. Pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Spectroscopy.pptx food analysis technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Encapsulation theory and applications.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Electronic commerce courselecture one. Pdf
The AUB Centre for AI in Media Proposal.docx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

computer notes - Data Structures - 3

  • 1. Class No.03 Data Structures http://ecomputernotes.com
  • 2. Linked List Actual picture in memory: 1051 1052 1055 1059 1060 1061 1062 1063 1064 1056 1057 1058 1053 1054 2 6 8 7 1 1051 1063 1057 1060 0 head 1054 1063 current 2 6 8 7 1 head current 1065 http://ecomputernotes.com
  • 3. Linked List Operations add(9): Create a new node in memory to hold ‘9’ Node* newNode = new Node(9); 9 newNode http://ecomputernotes.com
  • 4. Linked List Operations add(9): Create a new node in memory to hold ‘9’ Node* newNode = new Node(9); Link the new node into the list 9 newNode 2 6 8 7 1 head current size=5 6 9 newNode 1 3 2 http://ecomputernotes.com
  • 5. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; }; http://ecomputernotes.com
  • 6. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 7. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 8. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 9. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 10. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 11. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 12. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 13. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 14. C++ Code for Linked List The Node class class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };  http://ecomputernotes.com
  • 15. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List http://ecomputernotes.com
  • 16. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 17. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 18. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 19. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 20. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 21. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 22. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 23. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 24. #include <stdlib.h> #include &quot;Node.cpp&quot; class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; }; C++ Code for Linked List  http://ecomputernotes.com
  • 25. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; }; http://ecomputernotes.com
  • 26. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 27. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 28. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 29. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 30. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 31. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 32. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 33. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 34. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 35. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 36. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 37. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 38. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 39. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 40. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };  http://ecomputernotes.com
  • 41. Building a Linked List headNode size=0 List list; http://ecomputernotes.com
  • 42. Building a Linked List headNode 2 headNode currentNode size=1 lastcurrentNode size=0 List list; list.add(2); http://ecomputernotes.com
  • 43. Building a Linked List headNode 2 headNode currentNode size=1 lastcurrentNode 2 6 headNode currentNode size=2 lastcurrentNode size=0 List list; list.add(2); list.add(6); http://ecomputernotes.com
  • 44. Building a Linked List List.add(8); list.add(7); list.add(1); 2 6 7 1 headNode currentNode size=5 lastcurrentNode 8 http://ecomputernotes.com
  • 45. C++ Code for Linked List int get() { if (currentNode != NULL) return currentNode->get(); }; http://ecomputernotes.com
  • 46. C++ Code for Linked List bool next() { if (currentNode == NULL) return false; lastCurrentNode = currentNode; currentNode = currentNode->getNext(); if (currentNode == NULL || size == 0) return false; else return true; }; http://ecomputernotes.com

Editor's Notes

  • #3: End of lecture 2 The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #4: The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #5: The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #6: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #7: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #8: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #9: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #10: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #11: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #12: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #13: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #14: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #15: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #16: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #17: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #18: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #19: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #20: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #21: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #22: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #23: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #24: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #25: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #26: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #27: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #28: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #29: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #30: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #31: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #32: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #33: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #34: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #35: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #36: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #37: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #38: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #39: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #40: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #41: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #42: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #43: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #44: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #45: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #46: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #47: End of lecture 3 The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.